package com.tangula.android.kashine.broadcast.db

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter

class DbInitEndBroadcast :  BroadcastReceiver {

    companion object {
        @JvmStatic
        val ACTION = "kashine:db:initialized"

        @JvmStatic
        fun send(context:Context):Unit{
            context.sendBroadcast(Intent(ACTION))
        }
    }

    val intentFilter = object:IntentFilter(){
        init {
            this.addAction(ACTION)
        }
    }

    val receiverFunc:(Context?, Intent?)->Unit

    constructor(context:Context, receiver:(Context?, Intent?)->Unit): super(){
        this.receiverFunc = receiver;
        context.registerReceiver(this, this.intentFilter)
    }

    override fun onReceive(context: Context?, intent: Intent?) {
        receiverFunc(context, intent)
    }
}